<?php

class Test_Abovo_Valid extends Solar_Test {
    
    private $_valid;
    
    public function __construct($config = array())
    {
        parent::__construct($config);
        
        $this->_valid = Solar::factory('Abovo_Valid');
    }
    
    public function testCountry()
    {
        // valid country
        $this->assertTrue($this->_valid->country('FI'));
        
        // not valid
        $this->assertFalse($this->_valid->country('AA'));
        
        // allow blank
        $this->assertTrue($this->_valid->country('', Solar_Valid::OR_BLANK));
    }
    
    public function testZip()
    {
        // strings allowed
        $this->assertTrue($this->_valid->zip('12345'));

        // valid zip
        $this->assertTrue($this->_valid->zip(12345));

        // invalid zip
        $this->assertFalse($this->_valid->zip(123456));
    }
    
    public function testVat()
    {
        // valid vat
        $this->assertTrue($this->_valid->vat('FI12345678'));
        
        // not valid
        $this->assertFalse($this->_valid->vat('123456789'));
        
        // not valid country
        $this->assertFalse($this->_valid->vat('AA12345678'));
        
        // numerical end part not allowed. int(+12345) is a valid numeric value
        $this->assertFalse($this->_valid->vat('FI+1234567'));
        
        // allow blank
        $this->assertTrue($this->_valid->vat('', Solar_Valid::OR_BLANK));
    }
    
    public function testTel()
    {
        $this->assertTrue($this->_valid->tel('+358405755645'));
        $this->assertFalse($this->_valid->tel('3581234567891'));
        $this->assertFalse($this->_valid->tel('+358 1234567891'));
        $this->assertFalse($this->_valid->tel('+35812345678911234'));
    }
    
    public function testWikiPage()
    {
        $this->assertTrue($this->_valid->wikiPage('Wiki_page'));
        $this->assertTrue($this->_valid->wikiPage('1234'));
        $this->assertFalse($this->_valid->wikiPage('wiki link'));
        $this->assertFalse($this->_valid->wikiPage(' wiki_link'));
    }
}
